<template>
    <div class="admin-organization-tree">
        <n-tree
            block-line
            :data="useAdmin.getOrganization"
            :default-expanded-keys="defaultExpandedKeys"
            :default-selected-keys="defaultExpandedKeys"
            key-field="value"
            selectable
            :node-props="nodeProps"
        />
    </div>
</template>

<script setup>
import {useAdminStore} from "@/stores/admin";

const useAdmin = useAdminStore()
const props = defineProps(['setCurrent'])

const nodeProps = ({option}) => {
    return {
        onClick() {
            let identity = ''
            if ('college' in option) {
                identity = '学院'
            } else if ('profession' in option) {
                identity = '专业';
            } else {
                identity = '学校'
            }
            props.setCurrent({
                identity,
                id: option.id,
                name: option.label,
                info: option.info,
            });
        },
    }
}
// 默认展开
const defaultExpandedKeys = ["00000"]
</script>

<style scoped lang="less">
.n-tree {
    font-size: 18px;
}
</style>